<?php

class Whiskey_Controller {


    //TODO this will load the database driver in the future
    public $db;

    function __construct()
    {
        //TODO this will instantiate the db driver using the registry

    }

    /**
     * Method used to load views and models
     * @param string    $mode Use either 'view' or 'model'
     * @param string    $name The name of the view or model, without the .php extension
     * @param array     $data Array of data that can optionally be passed to a view
     */
    function load($mode, $name, $data = null) {

        switch($mode):
            case 'view':
                //if data is an array, extract the data
                if(is_array($data)) extract($data);

                //load the requested view
                if(file_exists(ROOT.'app/views/'.  strtolower($name) . '.php'))
                {
                    include ROOT.'app/views/'.strtolower($name).'.php';
                }
                else
                {
                    trigger_error("
                        View '" . $name . "' cannot be found. Check if the
                        view exists in the app/views folder<br>", E_USER_WARNING);
                }
                break;
            case 'model':

                break;
            default:
                    trigger_error("Invalid mode type used in load method of controller. Muse be either 'view' or 'model'.", E_USER_WARNING);
                    return;
        endswitch;

    }
}